package com.minshenglife.zanzan.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.minshenglife.zanzan.dao.UserSoftDao;
import com.minshenglife.zanzan.entity.UserSoft;
import com.minshenglife.zanzan.result.UserSoftResult;
import com.minshenglife.zanzan.service.UserSoftService;

/**
 * 
 * @author 867101835
 *
 */
@Component
@Transactional
public class UserSoftServiceImpl implements UserSoftService {
	Logger log = LoggerFactory.getLogger(UserSoftServiceImpl.class);
	@Resource
	UserSoftDao userSoftDao;

	@Override
	public String getAllManagerEmpId(String postId) {
		String AllManageEmpId = "";
		List<UserSoftResult> userSofts = userSoftDao.findAllUserByPostId(postId.toUpperCase());
		if(userSofts.size()==0)
			return null;
		for (UserSoftResult userSoftResult : userSofts) {
			AllManageEmpId += userSoftResult.getEmpName() +"("+userSoftResult.getEmpId()+")"+ "|";
		}
		return AllManageEmpId;
	}

	@Override
	public void add(UserSoft userSoft) {
		// TODO Auto-generated method stub
		userSoftDao.add(userSoft);
	}

	@Override
	public void deleteAllByPostId(String postId) {
		// TODO Auto-generated method stub
		userSoftDao.deleteAllByPostId(postId);
	}

	@Override
	public String getAllManagerEmpIdByViewType(String postId, String viewType) {
		String AllManageEmpId = "";
		Map<String,String> map = new HashMap<String,String>();
		map.put("postId", postId);
		map.put("viewType", viewType);
		List<UserSoftResult> userSofts = userSoftDao.findAllUserByPostIdAndViewType(map);
		if(userSofts.size()==0)
			return null;
		for (UserSoftResult userSoftResult : userSofts) {
			AllManageEmpId += userSoftResult.getEmpName() +"("+userSoftResult.getEmpId()+")"+ "|";
		}
		return AllManageEmpId;
	}


}
